import pandas as pd


def interval_transform(col_series: pd.Series, left, right, val, closed='left'):
    interval = pd.Interval(left=left, right=right, closed=closed)

    def func(row):
        if row in interval:
            return val
        else:
            return row

    return col_series.apply(func)


if __name__ == '__main__':
    pd_data = pd.DataFrame(
        [[1, 33, 4], [4, 4, 6], [12, 7, 99], [34, 54, 22], [23, 56, 2]],
        columns=['x_0', 'x_1', 'x_2'])

    print(pd_data)

    pd_data['x_0'] = interval_transform(pd_data['x_0'], 1, 200, 3)
    print(pd_data)
